import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import 'font-awesome/css/font-awesome.min.css';
import * as echarts from 'echarts'
import axios from 'axios'
import commonJs from '@/assets/js/common.js'
import constant from '@/assets/js/constant.js'

Vue.prototype.$axios = axios
Vue.prototype.$echarts = echarts
Vue.use(ElementUI);
Vue.config.productionTip = false
Vue.prototype.$commonJs = commonJs
Vue.prototype.$constant = constant

//设置接口请求的前缀地址
axios.defaults.baseURL = 'http://localhost:9000/api'

//全局设置token
axios.interceptors.request.use(function (config){
  let token = sessionStorage.getItem('token')
  if(token){
    config.headers['token'] = token
  }
  return config
}), function(err) {
  return Promise.reject(err)
}

axios.interceptors.response.use(function (response){
  return response
}), function(err) {
  return Promise.reject(err)
}

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
